package cn.tedu.user.management.dao.persist.repository.impl;

import cn.tedu.user.management.dao.persist.mapper.RentMapper;
import cn.tedu.user.management.dao.persist.repository.IRentRepository;
import cn.tedu.user.management.pojo.entity.Rent;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository
public class RentRepositoryImpl implements IRentRepository {

    @Autowired
    RentMapper rentMapper;
    @Override
    public int deleteByUserId(Long id) {
        log.debug("开始执行【根据user_id删除租用记录】的操作，参数：{}", id);
        return rentMapper.deleteByUserId(id);
    }

    @Override
    public int countByUserId(Long id) {
        log.debug("开始执行【根据user_id统计租用记录的数量】的数据访问，参数：{}", id);
        QueryWrapper<Rent> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        return rentMapper.selectCount(queryWrapper);
    }
}
